package 多线程05_线程交互;

import 多线程01_启动线程.Hero;

/**
 * @ClassName: TestThreadWaitNotify
 * @Author: AllenSun
 * @Date: 2022/3/18 下午11:01
 */
public class TestThreadWaitNotify {
    public static void main(String[] args) {
        final Hero gareen = new Hero("盖伦",616);

        Thread thread1 = new Thread() {
            public void run() {
                while (true) {
                    gareen.hurt_wait();
                    try {
                        Thread.sleep(10);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        };
        thread1.start();

        Thread thread2 = new Thread() {
            public void run() {
                while (true) {
                    gareen.recover_notify();
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        };
        thread2.start();

    }
}
